﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Rendering.RendererUtils.RendererListParams
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

#nullable disable
namespace UnityEngine.Rendering.RendererUtils
{
  internal struct RendererListParams
  {
    private static readonly ShaderTagId s_EmptyName = new ShaderTagId("");
    public static readonly RendererListParams nullRendererList = new RendererListParams();
    internal CullingResults cullingResult;
    internal DrawingSettings drawSettings;
    internal FilteringSettings filteringSettings;
    internal RenderStateBlock? stateBlock;

    public bool isValid { get; private set; }

    internal static RendererListParams Create(in RendererListDesc desc)
    {
      RendererListParams rendererListParams = new RendererListParams();
      if (!desc.IsValid())
        return rendererListParams;
      SortingSettings sortingSettings = new SortingSettings(desc.camera)
      {
        criteria = desc.sortingCriteria
      };
      DrawingSettings drawingSettings = new DrawingSettings(RendererListParams.s_EmptyName, sortingSettings)
      {
        perObjectData = desc.rendererConfiguration
      };
      if (desc.passName != ShaderTagId.none)
      {
        Debug.Assert(desc.passNames == null);
        drawingSettings.SetShaderPassName(0, desc.passName);
      }
      else
      {
        for (int index = 0; index < desc.passNames.Length; ++index)
          drawingSettings.SetShaderPassName(index, desc.passNames[index]);
      }
      if ((Object) desc.overrideMaterial != (Object) null)
      {
        drawingSettings.overrideMaterial = desc.overrideMaterial;
        drawingSettings.overrideMaterialPassIndex = desc.overrideMaterialPassIndex;
      }
      FilteringSettings filteringSettings = new FilteringSettings(new RenderQueueRange?(desc.renderQueueRange), desc.layerMask)
      {
        excludeMotionVectorObjects = desc.excludeObjectMotionVectors
      };
      rendererListParams.isValid = true;
      rendererListParams.cullingResult = desc.cullingResult;
      rendererListParams.drawSettings = drawingSettings;
      rendererListParams.filteringSettings = filteringSettings;
      rendererListParams.stateBlock = desc.stateBlock;
      return rendererListParams;
    }
  }
}
